#! /bin/bash

echo "build first, then run this scripts."

checkError() {
    error=$?

    if [ $error -ne 0 ]; then
        echo "found error: $error"
        exit $error
    fi
}

echo $OSTYPE

echo "distributing .so .h, lib, ..."
rm -rf ./dist
mkdir -p ./dist/lib
mkdir -p ./dist/include/QtPropertyBrowser

if [ "$OSTYPE" == "msys" ]; then
    mkdir -p ./dist/bin
    cp ./src/x64/Release/QtSolutions_PropertyBrowser-head.dll ./dist/bin/
    cp ./src/x64/Release/QtSolutions_PropertyBrowser-head.lib ./dist/lib/
    cp ./src/x64/Debug/QtSolutions_PropertyBrowser-headd.dll ./dist/bin/
    cp ./src/x64/Debug/QtSolutions_PropertyBrowser-headd.lib ./dist/lib/
else
    cp ./build/libQtPropertyBrowser.so ./dist/lib/
fi

cp ./src/* ./dist/include/QtPropertyBrowser/
rm -f ./dist/include/QtPropertyBrowser/*.cpp
rm -f ./dist/include/QtPropertyBrowser/*_rc.py
rm -f ./dist/include/QtPropertyBrowser/qtpropertybrowser.qrc
rm -f ./dist/include/QtPropertyBrowser/QtPropertyBrowser.sln
rm -f ./dist/include/QtPropertyBrowser/QtPropertyBrowser.vcxproj
rm -f ./dist/include/QtPropertyBrowser/*.vcxproj.*
